﻿try {
	Write-Host "Stopping the World Wide Web Publishing Service"
	Stop-Service W3SVC
	Write-Host "Opening configuration"
	$XmlFilePath = "$env:SystemRoot\System32\inetsrv\config\applicationHost.config"
	[Xml]$ConfigXml = Get-Content($XmlFilePath)
	Write-Host "Configuring default ping settings"
	$Node = $ConfigXml.SelectSingleNode("/configuration/system.applicationHost/applicationPools/applicationPoolDefaults/processModel")		
	$Node.SetAttribute("pingingEnabled","false") 
	foreach($Node in $ConfigXml.SelectNodes("/configuration/system.applicationHost/applicationPools/add")){
		$ProcessModelNode = $Node.processModel
		if($ProcessModelNode -ne $null){
			Write-Host "Configuring ping settings on application pool $($Node.name)"
			$ProcessModelNode.SetAttribute("pingingEnabled","false") 
		}else {
			Write-Host "Skipping application pool $($Node.name)"
		}
	}
	Write-Host "Saving configuration"
	$ConfigXml.Save($XmlFilePath)
} finally {
	Write-Host "Starting the World Wide Web Publishing Service"
	Start-Service W3SVC
}